<template>
    <div>
        <!-- 编辑弹出框 -->
        <el-dialog v-model="dialogFormVisible" title="Shipping address">
            <el-form :model="editData" label-width="100px">
                <el-form-item label="科室名称" prop="name">
                    <el-input v-model="editData.data.name" />
                </el-form-item>
                <el-form-item label="科室主任" prop="maindoctor">
                    <el-select v-model="editData.data.maindoctor" placeholder="Please select a zone">
                        <el-option label="医生" value="医生" />
                        <el-option label="护士" value="护士" />
                        <el-option label="医务管理员" value="医务管理员" />
                        <el-option label="实习助理" value="实习助理" />
                        <el-option label="药房" value="药房" />
                    </el-select>
                </el-form-item>
                <el-form-item label="创建时间" prop="createtime">
                    <el-input v-model="editData.data.createtime" />
                </el-form-item>
                <el-form-item label="科室编号" prop="id">
                    <el-input v-model="editData.data.id" />
                </el-form-item>
            </el-form>
            <template #footer>
                <span class="dialog-footer">
                    <el-button type="primary" @click="changeEdit">
                        确定编辑
                    </el-button>
                    <el-button @click="dialogFormVisible = false">取消编辑</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>

<script setup lang="ts">
import { reactive, ref, watchEffect } from 'vue';
import { departmentEditReq } from '@/API/Synthesis.api'
import { ElMessage, } from 'element-plus'
type Ityp = {
    createtime: string
    id: number
    maindoctor: string
    name: string
}
const props = defineProps({
    data: {
        type: Object,
        defalut: () => { }
    }
})
/**编辑对话框功能 */
const dialogFormVisible = ref(false)
const editData = reactive({
    data: {
        createtime: '',
        id: 0,
        maindoctor: '',
        name: ''
    }
})
const show = () => {
    dialogFormVisible.value = true
    editData.data = (props.data as Ityp)
}
const changeEdit = async () => {
    const res = await departmentEditReq(editData.data)
    console.log(res);
    if (res.data.code === 1) {
        ElMessage({
            type: 'success',
            message: res.data.msg,
        })
    } else {
        ElMessage({
            type: 'info',
            message: res.data.msg,
        })
    }
    dialogFormVisible.value = false
}
watchEffect(() => {
    show()
})
</script>

<style scoped>

</style>